﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace DLL.Message
{
	/// <summary>
	/// 视图控制类
	/// </summary>
	/// <![CDATA[2014-8-7 17:52:59]]>
	public class View : DLL.ShowLayer.FormView
	{
		private Component clsthisComp;

		#region 添加、修改
		/// <summary>
		/// 姓名
		/// </summary>
		private TextBox tbName = new TextBox();
		private TextBox tbEMail = new TextBox();
		private TextBox tbPhone = new TextBox();
		private TextBox tbMessage = new TextBox();
		private TextBox tbAnswer = new TextBox();
		#endregion 添加、修改

		#region 查询

		#endregion 查询

		#region 浏览

		#endregion 浏览

		#region 构造函数
		/// <summary>
		/// 视图类构造函数
		/// </summary>
		/// <![CDATA[2014-10-5 10:41:45]]>
		public View(System.Web.UI.Page page)
			: base(page)
		{
			clsthisComp = new Component(page);

			clsComp = clsthisComp;

			tbMessage.TextMode = TextBoxMode.MultiLine;
			tbMessage.Rows = 6;
			tbMessage.Columns = 40;
			tbAnswer.TextMode = TextBoxMode.MultiLine;
			tbAnswer.Rows = 6;
			tbAnswer.Columns = 40;
			listAddEdit.Add(new TonyNet4V1.Structs.TitleControlEntity("姓名", "TextBox", tbName, "string", "strPersonName"));
			listAddEdit.Add(new TonyNet4V1.Structs.TitleControlEntity("电子邮箱", "TextBox", tbEMail, "string", "strEMail"));
			listAddEdit.Add(new TonyNet4V1.Structs.TitleControlEntity("联系电话", "TextBox", tbPhone, "string", "strPhone"));
			listAddEdit.Add(new TonyNet4V1.Structs.TitleControlEntity("留言", "TextBox", tbMessage, "string", "strContent"));
			listAddEdit.Add(new TonyNet4V1.Structs.TitleControlEntity("回复", "TextBox", tbAnswer, "string", "strAnswer"));
		}
		#endregion 构造函数

		#region 类型转换

		protected override TonyNet4V1.EntityBase GetEntity()
		{
			return new Entity();
		}

		protected override TonyNet4V1.QueryEntityBase GetQuery()
		{
			return new QueryEntity();
		}

		protected override TonyNet4V1.ComponentBase GetComponent()
		{
			return clsthisComp;
		}

		#endregion 类型转换

		public override bool Update(int nUpdateID)
		{
			//return base.Update(nUpdateID);
			Entity clsEntity = new Entity();

			clsEntity = clsthisComp.GetOne(nUpdateID);
			ControlToEntity(clsEntity, listAddEdit);

			if (clsComp.Modify(clsEntity))
			{
				TonyNet4V1.ShowMessageAlert.ShowMessage(clsPage, "回复成功！");
				return true;
			}
			else
			{
				//Common.ShowMessageAlert.ShowMessage(Page, clsComp.GetNewestError());
				return false;
			}
		}
	}
}
